package com.jse.util.collection.map;

import java.util.LinkedHashMap;
import java.util.Map;

import org.junit.Test;

public class LinkedHashMapTest {

	/**
	 * LinkedHashMap保存了插入顺序，迭代出来也是按顺序排列
	 * 
	 * TreeMap实现了SortedMap接口，key进行了比较排序，迭代出来的key也是排序了的
	 */
	@Test
	public void testLoop() {
//		Map<String, String> map = new HashMap<>();
		Map<String, String> map = new LinkedHashMap<>();
		
		for (int i = 0; i < 100; i++) {
			map.put("a" + i, "a" + i);
		}
		
		for (Map.Entry<String, String> entry : map.entrySet()) {
			System.out.println("key:" + entry.getKey() + "," + "value:" + entry.getValue());
		}
	}
}
